<h2 class="popover-title">Bạn bè</h2>
<div id="notification">
  <?php if (isset($success)) : ?>
    <?php if ($success == true) : ?>
      <div class="alert alert-success"><?= $msg ?></div>
    <?php else : ?>
      <div class="alert alert-error"><?= $msg ?></div>
    <?php endif; ?>
  <?php endif; ?>
</div>
<div id="action">
  <a class="btn btn-success" href="<?= URL ?>?page=ban_be&act=add_new">
    <i class="icon-white icon-plus"></i> Thêm mới
  </a>
</div>
<table class="table table-striped table-bordered table-condensed">
  <thead>
    <tr>
      <th>#</th>
      <th class="yellow">Họ tên</th>
      <th class="blue">Nhóm</th>
      <th class="green">Mail</th>
      <th></th>
    </tr>
  </thead>
  <tbody>
    <?php $count = 0; foreach ($friends as $friend): ?>
    <tr>
      <td><?= ++$count ?></td>
      <td><?= $friend['fullname'] ?></td>
      <td>
        <?php if (!empty($friend['friend_groups'])) :
          $groups = $friend['friend_groups']; 
        ?>

          <?php for ($i = 0; $i < count($groups) - 1; $i++): ?>
            <a href="<?= URL ?>?page=nhom_ban_be&act=edit&friend_group_id=<?= $groups[$i]['friend_group_id'] ?>"><?= $groups[$i]['name'] ?></a>, 
          <?php endfor; ?>
            <a href="<?= URL ?>?page=nhom_ban_be&act=edit&friend_group_id=<?= $groups[$i]['friend_group_id'] ?>"><?= $groups[$i]['name'] ?></a>
          <?php endif; ?>
        </td>
        <td><?= $friend['mail'] ?></td>
        <td>
          <a href="<?= URL ?>?page=ban_be&act=edit&friend_id=<?= $friend['friend_id'] ?>" class="btn btn-mini" title="Sửa"><i class="icon-edit"></i></a>
          <a href="<?= URL ?>?page=ban_be&act=delete&friend_id=<?= $friend['friend_id'] ?>" class="btn btn-mini btn_delete" title="Xóa"><i class="icon-trash"></i></a>
        </td>
      </tr>
      <?php endforeach; ?>
  </tbody>
</table>